<%--
  @author Supun Nimesh Karunathilaka
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript">
    $(document).ready(function() {
//        if(document.getElementById("userName").value == "admin"){
//            $("#userList").hide();
//        }

        $('.land-table').dataTable({
                    "oTableTools": {
                        "aButtons": [
                            {
                                "sExtends": "print",
                                "bShowAll": true
                            }
                        ]
                    }
                });
    });
</script>
<div id="user-module-home-title" class="module-home-title">
    <s:a href="userModule.do"><img src="${pageContext.request.contextPath}/images/user.png"
                                   alt="User Module"><span><s:label
            value="%{getText('user_module.label')}"/></span></s:a>
    <div id="back-button" align="right">
        <s:submit type="input" value="%{getText('back.label')}" onclick="goBack();"/>
    </div>
</div>
<div id="update-user-div">
    <h2><s:label value="%{getText('update_user.label')}"/></h2>
    <s:if test="hasActionErrors() || hasActionMessages()">
        <div id="message-box" class="message-box">
            <div class="action-msg"><s:actionmessage/></div>
            <div class="action-err"><s:actionerror/></div>
        </div>
    </s:if>

    <table>
        <tr>
            <s:form name="searchUsersByRole" id="searchUsersByRole" method="POST">
        <tr>
            <td class="left-align"><s:label value="%{getText('role_id.label')}"/></td>
            <td><s:select id="roleId" name="roleId" list="roleSet" headerKey="0"
                          headerValue="%{getText('select.label')}"/></td>
            <td><s:submit action="searchUsersByRole" value="%{getText('search.label')}"/></td>
        </tr>

        </s:form>
        </tr>
    </table>
    </br>

    <table class="width-100 margin-10-auto table land-table">
        <thead>
        <tr class="left-align table-header">
            <th class=""><s:label value="%{getText('user_name.label')}"/></th>
            <th class=""><s:label value="%{getText('full_name.label')}"/></th>
            <th class=""><s:label value="%{getText('email.label')}"/></th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        <s:iterator status="status1" value="userList" var="user">
            <tr class="<s:if test="#status1.odd == true">able-row-odd</s:if><s:else>table-row-even</s:else>t">
                <td class="left-align"><s:property value="username"/></td>
                <td class="left-align"><s:property value="fullName"/></td>
                <td class="left-align"><s:property value="email"/></td>
                <td class="right-align">
                    <s:url id="updateUser" action="updateUserForm">
                        <s:param name="userId" value="username"/>
                    </s:url>
                    <s:a href="%{updateUser}">
                        <img src="<s:url value='/images/modify-form.png'/>" border="none" width="25"
                             height="25"/>
                    </s:a>
                </td>
            </tr>
        </s:iterator>
        </tbody>
    </table>
</div>

